
package com.market.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.market.bean.Productcritique;

public class ProCriServiceImpl extends BaseServiceImpl implements IProCriService
{
    public Productcritique findById(long id)
    {
        return getProCriDAO().findById(id);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.market.service.IProCriService#findByProduct(com.market.bean.Product)
     */
    public List findByProduct(long productid, int start, int max)
    {
        DetachedCriteria detachCri = DetachedCriteria.forClass(Productcritique.class);
        detachCri.add(Restrictions.eq("productid", new Long(productid)));
        detachCri.addOrder(Order.desc("adddate"));
        return getProCriDAO().findByDetchedCriteria(detachCri, start, max);
    }

    public int getCountByProduct(long productid)
    {
        DetachedCriteria detachCri = DetachedCriteria.forClass(Productcritique.class);
        detachCri.add(Restrictions.eq("productid", new Long(productid)));
        return getProCriDAO().getCountByDetachedCriteria(detachCri);
    }
}
